/*
 * BaseProjectInfoBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-06
 */

package com.bjtech.domain.query;

import java.util.Date;

import org.ssi.web.util.QuerySpecTpl;

import com.bjtech.web.util.SelectBean;

/**
 * 功能概述:项目信息管理 <br>
 * 
 * @author 王峰
 */

public class BaseProjectInfoQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private String proj_code;
	/* */
	private String proj_name;
	/* */
	private Long p_index;
	/* */
	private Long heat_station_id;
	/* */
	private Long community_id;
	/* */
	private String linka_man;
	/* */
	private String linka_tel;
	/* */
	private String agent_man;
	/* */
	private String agent_tel;
	/* */
	private String work_unit_man;
	/* */
	private String work_unit_tel;
	/* */
	private String work_fz_man;
	/* */
	private String tech_fz_man;
	/* */
	private String sale_fz_man;
	/* */
	private String serv_fz_man;
	/* */
	private String meter_reader;
	/* */
	private String work_account;
	/* */
	private Long phrase;
	/* */
	private String demo;
	
	private String proj_date; 
	
	private Integer user_role;
	
	private Long project_id;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

	//	if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(proj_code)) {
				fromPart.append(" and a.proj_code= ");
				fromPart.append(proj_code);
//				fromPart.append(" and a.proj_code like ");
//				fromPart.append(" CONCAT('%','");
//				fromPart.append(proj_code);
//				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(proj_name)) {
				fromPart.append(" and a.proj_name like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(proj_name);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(p_index)) {
				fromPart.append(" and a.p_index = ");
				fromPart.append(p_index);
			}

			if (QuerySpecTpl.isValid(heat_station_id)) {
				fromPart.append(" and a.heat_station_id = ");
				fromPart.append(heat_station_id);
			}

			if (QuerySpecTpl.isValid(community_id)) {
				fromPart.append(" and a.community_id = ");
				fromPart.append(community_id);
			}

			if (QuerySpecTpl.isValid(linka_man)) {
				fromPart.append(" and a.linka_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(linka_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(linka_tel)) {
				fromPart.append(" and a.linka_tel like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(linka_tel);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(agent_man)) {
				fromPart.append(" and a.agent_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(agent_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(agent_tel)) {
				fromPart.append(" and a.agent_tel like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(agent_tel);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(work_unit_man)) {
				fromPart.append(" and a.work_unit_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(work_unit_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(work_unit_tel)) {
				fromPart.append(" and a.work_unit_tel like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(work_unit_tel);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(work_fz_man)) {
				fromPart.append(" and a.work_fz_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(work_fz_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(tech_fz_man)) {
				fromPart.append(" and a.tech_fz_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(tech_fz_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(sale_fz_man)) {
				fromPart.append(" and a.sale_fz_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(sale_fz_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(serv_fz_man)) {
				fromPart.append(" and a.serv_fz_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(serv_fz_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(meter_reader)) {
				fromPart.append(" and a.meter_reader like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(meter_reader);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(work_account)) {
				fromPart.append(" and a.work_account like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(work_account);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(phrase)) {
				fromPart.append(" and a.phrase = ");
				fromPart.append(phrase);
			}

			if (QuerySpecTpl.isValid(demo)) {
				fromPart.append(" and a.demo like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(demo);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(proj_date)) {
				fromPart.append(" and str_to_date(a.proj_date,'%Y-%m-%d')=str_to_date('");
				fromPart.append(proj_date);
				fromPart.append("','%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(user_role)&&user_role.intValue()!=1) {
				if (QuerySpecTpl.isValid(project_id)) {
					fromPart.append(" and a.id = ");
					fromPart.append(project_id);
				}
			}
			
			
			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("asc");
			}
		//}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getProj_code() {
		return this.proj_code;
	}

	public void setProj_code(String proj_code) {
		this.proj_code = proj_code;
	}

	public String getProj_name() {
		return this.proj_name;
	}

	public void setProj_name(String proj_name) {
		this.proj_name = proj_name;
	}

	public Long getP_index() {
		return this.p_index;
	}

	public void setP_index(Long p_index) {
		this.p_index = p_index;
	}

	public Long getHeat_station_id() {
		return this.heat_station_id;
	}

	public void setHeat_station_id(Long heat_station_id) {
		this.heat_station_id = heat_station_id;
	}

	public Long getCommunity_id() {
		return this.community_id;
	}

	public void setCommunity_id(Long community_id) {
		this.community_id = community_id;
	}

	public String getLinka_man() {
		return this.linka_man;
	}

	public void setLinka_man(String linka_man) {
		this.linka_man = linka_man;
	}

	public String getLinka_tel() {
		return this.linka_tel;
	}

	public void setLinka_tel(String linka_tel) {
		this.linka_tel = linka_tel;
	}

	public String getAgent_man() {
		return this.agent_man;
	}

	public void setAgent_man(String agent_man) {
		this.agent_man = agent_man;
	}

	public String getAgent_tel() {
		return this.agent_tel;
	}

	public void setAgent_tel(String agent_tel) {
		this.agent_tel = agent_tel;
	}

	public String getWork_unit_man() {
		return this.work_unit_man;
	}

	public void setWork_unit_man(String work_unit_man) {
		this.work_unit_man = work_unit_man;
	}

	public String getWork_unit_tel() {
		return this.work_unit_tel;
	}

	public void setWork_unit_tel(String work_unit_tel) {
		this.work_unit_tel = work_unit_tel;
	}

	public String getWork_fz_man() {
		return this.work_fz_man;
	}

	public void setWork_fz_man(String work_fz_man) {
		this.work_fz_man = work_fz_man;
	}

	public String getTech_fz_man() {
		return this.tech_fz_man;
	}

	public void setTech_fz_man(String tech_fz_man) {
		this.tech_fz_man = tech_fz_man;
	}

	public String getSale_fz_man() {
		return this.sale_fz_man;
	}

	public void setSale_fz_man(String sale_fz_man) {
		this.sale_fz_man = sale_fz_man;
	}

	public String getServ_fz_man() {
		return this.serv_fz_man;
	}

	public void setServ_fz_man(String serv_fz_man) {
		this.serv_fz_man = serv_fz_man;
	}

	public String getMeter_reader() {
		return this.meter_reader;
	}

	public void setMeter_reader(String meter_reader) {
		this.meter_reader = meter_reader;
	}

	public String getWork_account() {
		return this.work_account;
	}

	public void setWork_account(String work_account) {
		this.work_account = work_account;
	}

	public Long getPhrase() {
		return this.phrase;
	}

	public void setPhrase(Long phrase) {
		this.phrase = phrase;
	}

	public String getDemo() {
		return this.demo;
	}

	public void setDemo(String demo) {
		this.demo = demo;
	}

	public String getProj_date() {
		return proj_date;
	}

	public void setProj_date(String projDate) {
		proj_date = projDate;
	}

	public Integer getUser_role() {
		return user_role;
	}

	public void setUser_role(Integer userRole) {
		user_role = userRole;
	}

	public Long getProject_id() {
		return project_id;
	}

	public void setProject_id(Long projectId) {
		project_id = projectId;
	}
}
